package gui;

import java.awt.Color;

import javax.swing.JTextPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants.ColorConstants;

@SuppressWarnings("serial")
public class MyJTextPane extends JTextPane {
	
	public MyJTextPane() {
		setOpaque(true);
		setBackground(Color.white);
		setEditable(false);
	}
	
	public void append(String line, Color c) {
		Document doc = getDocument();
        SimpleAttributeSet set = new SimpleAttributeSet();
        ColorConstants.setForeground(set, c);

		try {
			doc.insertString(doc.getLength(), line, set);
			doc.insertString(doc.getLength(), "\n", null);
		} catch (BadLocationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void append(String line) {
		append(line, Color.BLACK);
	}
}
